/* ============================================================
   SAWERIA-INSPIRED DARK THEME — ZERO EXTERNAL DEPENDENCIES
   ============================================================ */

  :root {
    --yellow:      #FFCC00;
    --yellow-h:    #FFD740;
    --yellow-dim:  rgba(255,204,0,0.12);
    --yellow-glow: rgba(255,204,0,0.28);
    --dark:        #0E0E0F;
    --card:        #1A1A1C;
    --card-h:      #222226;
    --border:      #2E2E32;
    --muted:       #6B6B70;
    --text:        #F0F0F0;
    --text-dim:    #A0A0A8;
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --font-sans:   'Plus Jakarta Sans', sans-serif;
    --font-mono:   'JetBrains Mono', monospace;
    --sidebar-w:   320px;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  html { height: 100%; }

  body {
    font-family: var(--font-sans);
    background: var(--dark);
    color: var(--text);
    min-height: 100vh;
    position: relative;
  }

  /* Noise overlay */
  body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.45;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: var(--card); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--yellow); }

  /* ---- HEADER ---- */
  header {
    position: sticky; top: 0; z-index: 50;
    height: 54px;
    background: rgba(14,14,15,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
  }
  .logo {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 15px; letter-spacing: -0.3px;
  }
  .logo-icon {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--yellow);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 14px;
    color: var(--dark);
    box-shadow: 0 4px 16px var(--yellow-glow);
  }
  .logo-badge {
    font-family: var(--font-mono); font-size: 10px;
    color: var(--muted);
    background: var(--card); border: 1px solid var(--border);
    padding: 2px 8px; border-radius: 20px;
  }
  .header-right {
    display: flex; align-items: center; gap: 8px;
  }
  .header-label {
    font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  }
  .blink-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--yellow);
    animation: blink 1.4s ease infinite;
  }

  /* ---- LAYOUT ---- */
  .app-wrapper {
  position: relative;
  z-index: 1;
  }

  /* ---- SIDEBAR ---- */
  aside {
  position: fixed;
  top: 54px; /* tinggi header */
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - 54px);
  background: var(--dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  }

  .sidebar-section {
    padding: 16px 16px 12px;
    display: flex; flex-direction: column; gap: 12px;
  }

  .section-divider { height: 1px; background: var(--border); margin: 0 16px; }

  .section-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.4px;
    color: var(--muted); margin-bottom: 2px;
  }
  .section-label.yellow { color: var(--yellow); }

  /* Titik box */
  .titik-box {
    background: var(--yellow-dim);
    border: 1.5px solid rgba(255,204,0,0.25);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
  }

  /* Fields */
  .field { display: flex; flex-direction: column; gap: 4px; }
  .field label { font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
  .field .hint  { font-size: 11px; color: var(--muted); line-height: 1.4; }

  input[type="number"],
  input[type="text"],
  select {
    font-family: var(--font-mono); font-size: 13px; color: var(--text);
    background: var(--card); border: 1.5px solid var(--border);
    border-radius: var(--radius-md); padding: 8px 11px;
    outline: none; width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
  }
  input:focus, select:focus {
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-glow);
    background: #1e1e20;
  }
  input[readonly] {
    color: var(--yellow); background: var(--dark);
    cursor: default; opacity: 0.75;
  }
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B70' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer; }

  /* Toggle switch */
  .toggle-row {
    display: flex; align-items: center; justify-content: space-between;
  }
  .toggle-label { font-size: 13.5px; font-weight: 700; color: var(--text); }
  .toggle-wrap { position: relative; width: 40px; height: 22px; cursor: pointer; }
  .toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
  .toggle-track {
    position: absolute; inset: 0;
    background: var(--border); border-radius: 22px;
    transition: background 0.2s;
  }
  .toggle-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  }
  .toggle-wrap input:checked ~ .toggle-track { background: var(--yellow); }
  .toggle-wrap input:checked ~ .toggle-thumb { transform: translateX(18px); }

  /* Collapsible */
  .collapsible { overflow: hidden; max-height: 0; transition: max-height 0.35s ease; }
  .collapsible.open { max-height: 600px; }
  .collapsible-inner { padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }

  /* Titik visual dots */
  .titik-visual { display: flex; flex-wrap: wrap; gap: 5px; }
  .titik-dot {
    width: 24px; height: 24px;
    border: 1.5px solid var(--yellow); border-radius: 5px;
    font-family: var(--font-mono); font-size: 9px; font-weight: 600;
    color: var(--yellow); background: rgba(255,204,0,0.08);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.12s; cursor: default;
  }
  .titik-dot:hover { transform: scale(1.18); }
  .titik-dot.more { border-style: dashed; opacity: 0.5; font-size: 10px; }

  /* Buttons */
  .btn-generate {
    width: 100%; background: var(--yellow);
    color: var(--dark); font-family: var(--font-sans);
    font-size: 14px; font-weight: 800;
    border: none; border-radius: var(--radius-md);
    padding: 12px 16px; cursor: pointer;
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 20px var(--yellow-glow);
    letter-spacing: -0.2px;
  }
  .btn-generate:hover { background: var(--yellow-h); box-shadow: 0 6px 28px var(--yellow-glow); }
  .btn-generate:active { transform: scale(0.97); }

  .btn-print {
    width: 100%; background: transparent;
    color: var(--text); font-family: var(--font-sans);
    font-size: 13px; font-weight: 600;
    border: 1.5px solid var(--border); border-radius: var(--radius-md);
    padding: 10px 16px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  .btn-print:hover { border-color: rgba(255,204,0,0.5); background: var(--yellow-dim); }
  .btn-print:disabled { opacity: 0.3; cursor: not-allowed; }

  .btn-reset {
    background: none; border: none; font-size: 12px;
    color: var(--muted); cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
    font-family: var(--font-sans); transition: color 0.15s;
  }
  .btn-reset:hover { color: var(--yellow); }

  .action-footer {
    display: flex; align-items: center; justify-content: space-between; margin-top: 2px;
  }
  #total-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

  /* ---- MAIN ---- */
  main {
  margin-left: var(--sidebar-w);
  height: calc(100vh - 54px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  }

  /* Sticky sub-header */
  .preview-bar {
    position: sticky; top: 0; z-index: 10;
    background: rgba(14,14,15,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  }
  .preview-title { font-size: 14px; font-weight: 800; letter-spacing: -0.3px; }

  .preview-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

  /* Stats chips */
  #stats-row { display: none; align-items: center; flex-wrap: wrap; gap: 6px; }
  .stat-chip {
    font-family: var(--font-mono); font-size: 11px; color: var(--muted);
    background: var(--card); border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 8px;
    display: flex; align-items: center; gap: 4px;
  }
  .stat-chip strong { color: var(--text); font-weight: 600; }
  .stat-chip strong.yellow { color: var(--yellow); }

  /* View buttons */
  #view-controls-single { display: none; align-items: center; gap: 5px; }
  .view-btn {
    width: 30px; height: 30px;
    background: var(--card); border: 1.5px solid var(--border);
    border-radius: 8px; cursor: pointer; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .view-btn:hover, .view-btn.active {
    border-color: var(--yellow); background: var(--yellow-dim); color: var(--yellow);
  }

  /* ---- EMPTY STATE ---- */
  #empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; min-height: 400px; gap: 16px; text-align: center; padding: 40px;
  }
  .empty-icon {
    width: 72px; height: 72px; border-radius: 18px;
    border: 2px dashed var(--border); background: var(--card);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 28px; color: var(--muted);
  }
  .empty-title { font-size: 16px; font-weight: 800; }
  .empty-sub { font-size: 13px; color: var(--muted); max-width: 300px; line-height: 1.7; }
  .empty-sub span { color: var(--yellow); font-weight: 600; }
  .empty-preview {
    display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; justify-content: center;
  }
  .empty-chip {
    font-family: var(--font-mono); font-size: 12px;
    background: var(--card); border: 1px solid var(--border);
    padding: 5px 12px; border-radius: 7px; color: var(--muted);
  }

  /* ---- PREVIEW CONTENT ---- */
  #preview-content { padding: 20px 24px; }

  /* Table */
  .nomor-table-wrap {
    border-radius: var(--radius-lg); border: 1px solid var(--border); overflow-x: auto;
  }
  #nomor-table { border-collapse: collapse; width: 100%; font-family: var(--font-mono); }

  #nomor-table thead th {
    background: #111113; color: var(--yellow);
    padding: 9px 14px; font-size: 10px; font-weight: 700;
    letter-spacing: 0.9px; text-align: center; white-space: nowrap;
    border-bottom: 2px solid var(--yellow);
    position: sticky; top: 0; z-index: 1;
  }
  #nomor-table thead th.row-head { color: var(--muted); background: var(--dark); }

  #nomor-table tbody td {
    border: 1px solid var(--border);
    padding: 6px 14px; text-align: center;
    color: var(--text); font-size: 12.5px; white-space: nowrap;
    transition: background 0.1s;
  }
  #nomor-table tbody td.row-num {
    background: var(--dark); color: var(--muted);
    font-size: 10px; border-right: 2px solid var(--border);
  }
  #nomor-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.025); }
  #nomor-table tbody tr:hover td:not(.row-num) { background: rgba(255,204,0,0.07); }
  #nomor-table tbody tr { animation: fadeup 0.2s ease both; }

  /* Card grid */
  #number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }
  #number-grid.large { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  #number-grid.small { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 7px; }

  .num-card {
    background: var(--card); border: 1.5px solid var(--border);
    border-radius: var(--radius-md); aspect-ratio: 7/4;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--text);
    position: relative; cursor: default;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s;
    animation: fadeup 0.22s ease both;
    overflow: hidden;
  }
  .num-card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,204,0,0.06), transparent 60%);
    opacity: 0; transition: opacity 0.2s;
  }
  .num-card:hover {
    border-color: var(--yellow);
    box-shadow: 0 0 0 1px var(--yellow), 0 4px 20px var(--yellow-glow);
    transform: translateY(-2px);
    background: var(--card-h);
  }
  .num-card:hover::before { opacity: 1; }
  .num-card .seq-num {
    position: absolute; top: 5px; left: 7px;
    font-size: 9px; color: var(--muted); opacity: 0.6;
  }
  .num-card.large { font-size: 18px; }
  .num-card.small { font-size: 11px; aspect-ratio: 3/2; }

  /* ---- ANIMATIONS ---- */
  @keyframes fadeup {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
  }

  /* ---- PRINT ---- */
  @media print {
    body::before { display: none; }
    header, aside, .preview-bar { display: none !important; }
    body, main { background: white !important; }
    .app-wrapper { display: block !important; }
    #preview-content { padding: 6mm !important; }
    .nomor-table-wrap { border: none !important; border-radius: 0 !important; overflow: visible !important; }
    #nomor-table thead th {
      background: #222 !important; color: #fff !important;
      padding: 4px 6px !important; font-size: 9px !important;
      -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    #nomor-table tbody td { padding: 3px 5px !important; font-size: 9px !important; color: #000 !important; background: white !important; }
    #nomor-table tbody tr:nth-child(even) td { background: #f5f5f5 !important; print-color-adjust: exact; }
    #number-grid { grid-template-columns: repeat(5, 1fr) !important; }
    .num-card { box-shadow: none !important; transform: none !important; border: 1px solid #ccc !important; background: white !important; break-inside: avoid; }
    .num-card::before { display: none; }
    .num-card span { color: #000 !important; }
  }

  /* ---- RESPONSIVE ---- */
  @media (max-width: 720px) {
    .app-wrapper { flex-direction: column; }
    aside { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    header { padding: 0 16px; }
    .header-label { display: none; }
    #preview-content { padding: 14px; }
    .preview-bar { padding: 8px 14px; }
  }